﻿using System;
using System.Diagnostics;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using HslCommunication.BasicFramework;
using HslCommunication.Core;
using HslCommunication.Core.Address;
using HslCommunication.Core.IMessage;
using HslCommunication.Core.Net;
using HslCommunication.Reflection;

namespace HslCommunication.Profinet.GE
{
	/// <summary>
	/// Ge(通用电气)集团的SRTP协议实现的客户端，支持 I,Q,M,T,SA,SB,SC,S,G 的位和字节读写，支持 AI,AQ,R 的字读写操作，支持读取PLC时间，程序名操作<br />
	/// The client implemented by Ge (General Electric) Group's SRTP protocol, supports I, Q, M, T, SA, SB, SC, S, G bit and byte read and write, 
	/// supports AI, AQ, R word read and write Operation, support reading PLC time, program name operation
	/// </summary>
	/// <remarks>
	/// PLC的端口号默认18245，其中读取R，AI，AQ寄存器的原始字节时，传入的长度参数为字节长度。<br />
	/// 对其他寄存器而言，M1-M8的位读取，相当于 M1的字节读取。写入也是同理。
	/// </remarks>
	/// <example>
	/// 地址支持的列表如下：
	/// <list type="table">
	///   <listheader>
	///     <term>地址名称</term>
	///     <term>地址代号</term>
	///     <term>示例</term>
	///     <term>地址进制</term>
	///     <term>位操作</term>
	///     <term>字节操作</term>
	///     <term>备注</term>
	///   </listheader>
	///   <item>
	///     <term>Discrete Inputs</term>
	///     <term>I</term>
	///     <term>I1,I100</term>
	///     <term>10</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term>注意：读位和字节，属于不同的地址</term>
	///   </item>
	///   <item>
	///     <term>Discrete Outputs</term>
	///     <term>Q</term>
	///     <term>Q1,Q100</term>
	///     <term>10</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term>注意：读位和字节，属于不同的地址</term>
	///   </item>
	///   <item>
	///     <term>Discrete Internals</term>
	///     <term>M</term>
	///     <term>M1,M100</term>
	///     <term>10</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term>注意：读位和字节，属于不同的地址</term>
	///   </item>
	///   <item>
	///     <term>Discrete Temporaries</term>
	///     <term>T</term>
	///     <term>T1,T100</term>
	///     <term>10</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term>注意：读位和字节，属于不同的地址</term>
	///   </item>
	///   <item>
	///     <term>SA Discrete</term>
	///     <term>SA</term>
	///     <term>SA1,SA100</term>
	///     <term>10</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term>注意：读位和字节，属于不同的地址</term>
	///   </item>
	///   <item>
	///     <term>SB Discrete</term>
	///     <term>SB</term>
	///     <term>SB1,SB100</term>
	///     <term>10</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term>注意：读位和字节，属于不同的地址</term>
	///   </item>
	///   <item>
	///     <term>SC Discrete</term>
	///     <term>SC</term>
	///     <term>SC1,SC100</term>
	///     <term>10</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term>注意：读位和字节，属于不同的地址</term>
	///   </item>
	///   <item>
	///     <term>S Discrete</term>
	///     <term>S</term>
	///     <term>S1,S100</term>
	///     <term>10</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term>注意：读位和字节，属于不同的地址</term>
	///   </item>
	///   <item>
	///     <term>Genius Global Data</term>
	///     <term>G</term>
	///     <term>G1,G100</term>
	///     <term>10</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term>注意：读位和字节，属于不同的地址</term>
	///   </item>
	///   <item>
	///     <term>Analog Inputs </term>
	///     <term>AI</term>
	///     <term>AI1,AI100</term>
	///     <term>10</term>
	///     <term>×</term>
	///     <term>√</term>
	///     <term>虽然读取的时候，长度是字节，但是实际是字单位的，所以不支持 ReadByte</term>
	///   </item>
	///   <item>
	///     <term>Analog Outputs </term>
	///     <term>QI</term>
	///     <term>QI1,QI100</term>
	///     <term>10</term>
	///     <term>×</term>
	///     <term>√</term>
	///     <term>虽然读取的时候，长度是字节，但是实际是字单位的，所以不支持 ReadByte</term>
	///   </item>
	///   <item>
	///     <term>Registers </term>
	///     <term>R</term>
	///     <term>R1,R100</term>
	///     <term>10</term>
	///     <term>×</term>
	///     <term>√</term>
	///     <term>虽然读取的时候，长度是字节，但是实际是字单位的，所以不支持 ReadByte</term>
	///   </item>
	/// </list>
	/// <note type="important">对于 AI,AQ,R 类型的数据来说，底层是以字为单位的，但是调用 <see cref="M:HslCommunication.Profinet.GE.GeSRTPNet.Read(System.String,System.UInt16)" /> 来读取原始数据时，需要传入2被的字长度，对于其他方法不影响</note>
	/// <code lang="cs" source="HslCommunication_Net45.Test\Documentation\Samples\Profinet\GeSRTPNetSample.cs" region="Usage" title="简单的短连接使用" />
	/// <code lang="cs" source="HslCommunication_Net45.Test\Documentation\Samples\Profinet\GeSRTPNetSample.cs" region="Usage2" title="简单的长连接使用" />
	///
	/// 假设起始地址为R1，R1存储了温度，100.6℃值为1006，R2存储了压力，1.23Mpa值为123，R3-R4存储了产量计数，读取如下：
	/// <code lang="cs" source="HslCommunication_Net45.Test\Documentation\Samples\Profinet\GeSRTPNetSample.cs" region="ReadExample2" title="Read示例" />
	/// 以下是读取不同类型数据的示例
	/// <code lang="cs" source="HslCommunication_Net45.Test\Documentation\Samples\Profinet\GeSRTPNetSample.cs" region="ReadExample1" title="Read示例" />
	/// </example>
	// Token: 0x0200009E RID: 158
	public class GeSRTPNet : NetworkDeviceBase
	{
		/// <summary>
		/// 实例化一个默认的对象<br />
		/// Instantiate a default object
		/// </summary>
		// Token: 0x06000BD0 RID: 3024 RVA: 0x00045E78 File Offset: 0x00044078
		public GeSRTPNet()
		{
			base.ByteTransform = new RegularByteTransform();
			base.WordLength = 2;
		}

		/// <summary>
		/// 指定IP地址和端口号来实例化一个对象<br />
		/// Specify the IP address and port number to instantiate an object
		/// </summary>
		/// <param name="ipAddress">Ip地址</param>
		/// <param name="port">端口号</param>
		// Token: 0x06000BD1 RID: 3025 RVA: 0x00045EAC File Offset: 0x000440AC
		public GeSRTPNet(string ipAddress, int port = 18245)
		{
			base.ByteTransform = new RegularByteTransform();
			this.IpAddress = ipAddress;
			this.Port = port;
			base.WordLength = 2;
		}

		/// <inheritdoc />
		// Token: 0x06000BD2 RID: 3026 RVA: 0x00045EF9 File Offset: 0x000440F9
		protected override INetMessage GetNewNetMessage()
		{
			return new GeSRTPMessage();
		}

		/// <inheritdoc />
		// Token: 0x06000BD3 RID: 3027 RVA: 0x00045F00 File Offset: 0x00044100
		protected override OperateResult InitializationOnConnect(Socket socket)
		{
			OperateResult<byte[]> operateResult = this.ReadFromCoreServer(socket, new byte[56], true, true);
			bool flag = !operateResult.IsSuccess;
			OperateResult result;
			if (flag)
			{
				result = operateResult;
			}
			else
			{
				result = OperateResult.CreateSuccessResult();
			}
			return result;
		}

		/// <inheritdoc />
		// Token: 0x06000BD4 RID: 3028 RVA: 0x00045F3C File Offset: 0x0004413C
		[DebuggerStepThrough]
		protected override Task<OperateResult> InitializationOnConnectAsync(Socket socket)
		{
			GeSRTPNet.<InitializationOnConnectAsync>d__4 <InitializationOnConnectAsync>d__ = new GeSRTPNet.<InitializationOnConnectAsync>d__4();
			<InitializationOnConnectAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<InitializationOnConnectAsync>d__.<>4__this = this;
			<InitializationOnConnectAsync>d__.socket = socket;
			<InitializationOnConnectAsync>d__.<>1__state = -1;
			<InitializationOnConnectAsync>d__.<>t__builder.Start<GeSRTPNet.<InitializationOnConnectAsync>d__4>(ref <InitializationOnConnectAsync>d__);
			return <InitializationOnConnectAsync>d__.<>t__builder.Task;
		}

		/// <summary>
		/// 批量读取字节数组信息，需要指定地址和长度，返回原始的字节数组，支持 I,Q,M,T,SA,SB,SC,S,G 的位和字节读写，支持 AI,AQ,R 的字读写操作，地址示例：R1,M1<br />
		/// Batch read byte array information, need to specify the address and length, return the original byte array.
		/// Support I, Q, M, T, SA, SB, SC, S, G bit and byte read and write, support AI, AQ, R word read and write operations, address examples: R1, M1
		/// </summary>
		/// <remarks>
		/// 其中读取R，AI，AQ寄存器的原始字节时，传入的长度参数为字节长度。长度为10，返回10个字节数组信息，如果返回长度不满6个字节的，一律返回6个字节的数据
		/// </remarks>
		/// <param name="address">数据地址</param>
		/// <param name="length">数据长度</param>
		/// <returns>带有成功标识的byte[]数组</returns>
		// Token: 0x06000BD5 RID: 3029 RVA: 0x00045F88 File Offset: 0x00044188
		[HslMqttApi("ReadByteArray", "")]
		public override OperateResult<byte[]> Read(string address, ushort length)
		{
			OperateResult<byte[]> operateResult = GeHelper.BuildReadCommand(this.incrementCount.GetCurrentValue(), address, length, false);
			bool flag = !operateResult.IsSuccess;
			OperateResult<byte[]> result;
			if (flag)
			{
				result = operateResult;
			}
			else
			{
				OperateResult<byte[]> operateResult2 = base.ReadFromCoreServer(operateResult.Content);
				bool flag2 = !operateResult2.IsSuccess;
				if (flag2)
				{
					result = operateResult2;
				}
				else
				{
					result = GeHelper.ExtraResponseContent(operateResult2.Content);
				}
			}
			return result;
		}

		/// <inheritdoc />
		// Token: 0x06000BD6 RID: 3030 RVA: 0x00045FEC File Offset: 0x000441EC
		[HslMqttApi("WriteByteArray", "")]
		public override OperateResult Write(string address, byte[] value)
		{
			OperateResult<byte[]> operateResult = GeHelper.BuildWriteCommand(this.incrementCount.GetCurrentValue(), address, value);
			bool flag = !operateResult.IsSuccess;
			OperateResult result;
			if (flag)
			{
				result = operateResult;
			}
			else
			{
				OperateResult<byte[]> operateResult2 = base.ReadFromCoreServer(operateResult.Content);
				bool flag2 = !operateResult2.IsSuccess;
				if (flag2)
				{
					result = operateResult2;
				}
				else
				{
					result = GeHelper.ExtraResponseContent(operateResult2.Content);
				}
			}
			return result;
		}

		/// <summary>
		/// 根据指定的地址来读取一个字节的数据，按照字节为单位，例如 M1 字节，就是指 M1-M8 位组成的字节，M2 字节就是 M9-M16 组成的字节。不支持对 AI,AQ,R 寄存器的字节读取<br />
		/// A byte of data is read according to the specified address, and the unit is byte. For example, M1 byte refers to a byte composed of M1-M8 bits, 
		/// and M2 byte is a byte composed of M9-M16. Does not support byte reading of AI, AQ, R registers
		/// </summary>
		/// <param name="address">地址信息</param>
		/// <returns>带有成功标识的 <see cref="T:System.Byte" /> 数据</returns>
		// Token: 0x06000BD7 RID: 3031 RVA: 0x00046050 File Offset: 0x00044250
		[HslMqttApi("ReadByte", "")]
		public OperateResult<byte> ReadByte(string address)
		{
			OperateResult<GeSRTPAddress> operateResult = GeSRTPAddress.ParseFrom(address, 1, true);
			bool flag = !operateResult.IsSuccess;
			OperateResult<byte> result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<byte>(operateResult);
			}
			else
			{
				bool flag2 = operateResult.Content.DataCode == 10 || operateResult.Content.DataCode == 12 || operateResult.Content.DataCode == 8;
				if (flag2)
				{
					result = new OperateResult<byte>(StringResources.Language.GeSRTPNotSupportByteReadWrite);
				}
				else
				{
					result = ByteTransformHelper.GetResultFromArray<byte>(this.Read(address, 1));
				}
			}
			return result;
		}

		/// <summary>
		/// 向PLC中写入byte数据，返回是否写入成功<br />
		/// Write byte data to PLC and return whether the writing is successful
		/// </summary>
		/// <param name="address">起始地址，格式为I100，M100，Q100，DB20.100 -&gt; Starting address, formatted as I100,mM100,Q100,DB20.100</param>
		/// <param name="value">byte数据 -&gt; Byte data</param>
		/// <returns>是否写入成功的结果对象 -&gt; Whether to write a successful result object</returns>
		// Token: 0x06000BD8 RID: 3032 RVA: 0x000460D4 File Offset: 0x000442D4
		[HslMqttApi("WriteByte", "")]
		public OperateResult Write(string address, byte value)
		{
			OperateResult<GeSRTPAddress> operateResult = GeSRTPAddress.ParseFrom(address, 1, true);
			bool flag = !operateResult.IsSuccess;
			OperateResult result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<byte>(operateResult);
			}
			else
			{
				bool flag2 = operateResult.Content.DataCode == 10 || operateResult.Content.DataCode == 12 || operateResult.Content.DataCode == 8;
				if (flag2)
				{
					result = new OperateResult<byte>(StringResources.Language.GeSRTPNotSupportByteReadWrite);
				}
				else
				{
					result = this.Write(address, new byte[]
					{
						value
					});
				}
			}
			return result;
		}

		/// <summary>
		/// 按照位为单位，批量从指定的地址里读取 bool 数组数据，不支持 AI，AQ，R 地址类型，地址比如从1开始，例如 I1,Q1,M1,T1,SA1,SB1,SC1,S1,G1<br />
		/// In units of bits, read bool array data from the specified address in batches. AI, AQ, 
		/// R address types are not supported. For example, the address starts from 1, such as I1, Q1, M1, T1, SA1, SB1, SC1, S1, G1
		/// </summary>
		/// <param name="address">PLC的地址信息，例如 M1, G1</param>
		/// <param name="length">读取的长度信息，按照位为单位</param>
		/// <returns>包含是否读取成功的bool数组</returns>
		// Token: 0x06000BD9 RID: 3033 RVA: 0x0004615C File Offset: 0x0004435C
		[HslMqttApi("ReadBoolArray", "")]
		public override OperateResult<bool[]> ReadBool(string address, ushort length)
		{
			OperateResult<GeSRTPAddress> operateResult = GeSRTPAddress.ParseFrom(address, length, true);
			bool flag = !operateResult.IsSuccess;
			OperateResult<bool[]> result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<bool[]>(operateResult);
			}
			else
			{
				OperateResult<byte[]> operateResult2 = GeHelper.BuildReadCommand(this.incrementCount.GetCurrentValue(), operateResult.Content);
				bool flag2 = !operateResult2.IsSuccess;
				if (flag2)
				{
					result = OperateResult.CreateFailedResult<bool[]>(operateResult2);
				}
				else
				{
					OperateResult<byte[]> operateResult3 = base.ReadFromCoreServer(operateResult2.Content);
					bool flag3 = !operateResult3.IsSuccess;
					if (flag3)
					{
						result = OperateResult.CreateFailedResult<bool[]>(operateResult3);
					}
					else
					{
						OperateResult<byte[]> operateResult4 = GeHelper.ExtraResponseContent(operateResult3.Content);
						bool flag4 = !operateResult4.IsSuccess;
						if (flag4)
						{
							result = OperateResult.CreateFailedResult<bool[]>(operateResult4);
						}
						else
						{
							result = OperateResult.CreateSuccessResult<bool[]>(operateResult4.Content.ToBoolArray().SelectMiddle(operateResult.Content.AddressStart % 8, (int)length));
						}
					}
				}
			}
			return result;
		}

		/// <summary>
		/// 按照位为单位，批量写入 bool 数组到指定的地址里，不支持 AI，AQ，R 地址类型，地址比如从1开始，例如 I1,Q1,M1,T1,SA1,SB1,SC1,S1,G1<br />
		/// In units of bits, write bool arrays in batches to the specified addresses. AI, AQ, and R address types are not supported. For example, 
		/// the address starts from 1, such as I1, Q1, M1, T1, SA1, SB1, SC1, S1, G1
		/// </summary>
		/// <param name="address">PLC的地址信息，例如 M1, G1</param>
		/// <param name="value">bool 数组</param>
		/// <returns>是否写入成功的结果对象</returns>
		// Token: 0x06000BDA RID: 3034 RVA: 0x00046234 File Offset: 0x00044434
		[HslMqttApi(ApiTopic = "WriteBoolArray", Description = "In units of bits, write bool arrays in batches to the specified addresses")]
		public override OperateResult Write(string address, bool[] value)
		{
			OperateResult<byte[]> operateResult = GeHelper.BuildWriteCommand(this.incrementCount.GetCurrentValue(), address, value);
			bool flag = !operateResult.IsSuccess;
			OperateResult result;
			if (flag)
			{
				result = operateResult;
			}
			else
			{
				OperateResult<byte[]> operateResult2 = base.ReadFromCoreServer(operateResult.Content);
				bool flag2 = !operateResult2.IsSuccess;
				if (flag2)
				{
					result = operateResult2;
				}
				else
				{
					result = GeHelper.ExtraResponseContent(operateResult2.Content);
				}
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.GE.GeSRTPNet.Read(System.String,System.UInt16)" />
		// Token: 0x06000BDB RID: 3035 RVA: 0x00046298 File Offset: 0x00044498
		[DebuggerStepThrough]
		public override Task<OperateResult<byte[]>> ReadAsync(string address, ushort length)
		{
			GeSRTPNet.<ReadAsync>d__11 <ReadAsync>d__ = new GeSRTPNet.<ReadAsync>d__11();
			<ReadAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult<byte[]>>.Create();
			<ReadAsync>d__.<>4__this = this;
			<ReadAsync>d__.address = address;
			<ReadAsync>d__.length = length;
			<ReadAsync>d__.<>1__state = -1;
			<ReadAsync>d__.<>t__builder.Start<GeSRTPNet.<ReadAsync>d__11>(ref <ReadAsync>d__);
			return <ReadAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.GE.GeSRTPNet.Write(System.String,System.Byte[])" />
		// Token: 0x06000BDC RID: 3036 RVA: 0x000462EC File Offset: 0x000444EC
		[DebuggerStepThrough]
		public override Task<OperateResult> WriteAsync(string address, byte[] value)
		{
			GeSRTPNet.<WriteAsync>d__12 <WriteAsync>d__ = new GeSRTPNet.<WriteAsync>d__12();
			<WriteAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<WriteAsync>d__.<>4__this = this;
			<WriteAsync>d__.address = address;
			<WriteAsync>d__.value = value;
			<WriteAsync>d__.<>1__state = -1;
			<WriteAsync>d__.<>t__builder.Start<GeSRTPNet.<WriteAsync>d__12>(ref <WriteAsync>d__);
			return <WriteAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.GE.GeSRTPNet.ReadByte(System.String)" />
		// Token: 0x06000BDD RID: 3037 RVA: 0x00046340 File Offset: 0x00044540
		[DebuggerStepThrough]
		public Task<OperateResult<byte>> ReadByteAsync(string address)
		{
			GeSRTPNet.<ReadByteAsync>d__13 <ReadByteAsync>d__ = new GeSRTPNet.<ReadByteAsync>d__13();
			<ReadByteAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult<byte>>.Create();
			<ReadByteAsync>d__.<>4__this = this;
			<ReadByteAsync>d__.address = address;
			<ReadByteAsync>d__.<>1__state = -1;
			<ReadByteAsync>d__.<>t__builder.Start<GeSRTPNet.<ReadByteAsync>d__13>(ref <ReadByteAsync>d__);
			return <ReadByteAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.GE.GeSRTPNet.Write(System.String,System.Byte)" />
		// Token: 0x06000BDE RID: 3038 RVA: 0x0004638C File Offset: 0x0004458C
		[DebuggerStepThrough]
		public Task<OperateResult> WriteAsync(string address, byte value)
		{
			GeSRTPNet.<WriteAsync>d__14 <WriteAsync>d__ = new GeSRTPNet.<WriteAsync>d__14();
			<WriteAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<WriteAsync>d__.<>4__this = this;
			<WriteAsync>d__.address = address;
			<WriteAsync>d__.value = value;
			<WriteAsync>d__.<>1__state = -1;
			<WriteAsync>d__.<>t__builder.Start<GeSRTPNet.<WriteAsync>d__14>(ref <WriteAsync>d__);
			return <WriteAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.GE.GeSRTPNet.ReadBool(System.String,System.UInt16)" />
		// Token: 0x06000BDF RID: 3039 RVA: 0x000463E0 File Offset: 0x000445E0
		[DebuggerStepThrough]
		public override Task<OperateResult<bool[]>> ReadBoolAsync(string address, ushort length)
		{
			GeSRTPNet.<ReadBoolAsync>d__15 <ReadBoolAsync>d__ = new GeSRTPNet.<ReadBoolAsync>d__15();
			<ReadBoolAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult<bool[]>>.Create();
			<ReadBoolAsync>d__.<>4__this = this;
			<ReadBoolAsync>d__.address = address;
			<ReadBoolAsync>d__.length = length;
			<ReadBoolAsync>d__.<>1__state = -1;
			<ReadBoolAsync>d__.<>t__builder.Start<GeSRTPNet.<ReadBoolAsync>d__15>(ref <ReadBoolAsync>d__);
			return <ReadBoolAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.GE.GeSRTPNet.Write(System.String,System.Boolean[])" />
		// Token: 0x06000BE0 RID: 3040 RVA: 0x00046434 File Offset: 0x00044634
		[DebuggerStepThrough]
		public override Task<OperateResult> WriteAsync(string address, bool[] value)
		{
			GeSRTPNet.<WriteAsync>d__16 <WriteAsync>d__ = new GeSRTPNet.<WriteAsync>d__16();
			<WriteAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<WriteAsync>d__.<>4__this = this;
			<WriteAsync>d__.address = address;
			<WriteAsync>d__.value = value;
			<WriteAsync>d__.<>1__state = -1;
			<WriteAsync>d__.<>t__builder.Start<GeSRTPNet.<WriteAsync>d__16>(ref <WriteAsync>d__);
			return <WriteAsync>d__.<>t__builder.Task;
		}

		/// <summary>
		/// <b>[商业授权]</b> 读取PLC当前的时间，这个时间可能是不包含时区的，需要自己转换成本地的时间。<br />
		/// <b>[Authorization]</b> Read the current time of the PLC, this time may not include the time zone, you need to convert the local time yourself.
		/// </summary>
		/// <returns>包含是否成功的时间信息</returns>
		// Token: 0x06000BE1 RID: 3041 RVA: 0x00046488 File Offset: 0x00044688
		[HslMqttApi(Description = "Read the current time of the PLC")]
		public OperateResult<DateTime> ReadPLCTime()
		{
			long currentValue = this.incrementCount.GetCurrentValue();
			byte code = 37;
			byte[] array = new byte[5];
			array[3] = 2;
			OperateResult<byte[]> operateResult = GeHelper.BuildReadCoreCommand(currentValue, code, array);
			bool flag = !operateResult.IsSuccess;
			OperateResult<DateTime> result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<DateTime>(operateResult);
			}
			else
			{
				OperateResult<byte[]> operateResult2 = base.ReadFromCoreServer(operateResult.Content);
				bool flag2 = !operateResult2.IsSuccess;
				if (flag2)
				{
					result = OperateResult.CreateFailedResult<DateTime>(operateResult2);
				}
				else
				{
					OperateResult<byte[]> operateResult3 = GeHelper.ExtraResponseContent(operateResult2.Content);
					bool flag3 = !operateResult3.IsSuccess;
					if (flag3)
					{
						result = OperateResult.CreateFailedResult<DateTime>(operateResult3);
					}
					else
					{
						result = GeHelper.ExtraDateTime(operateResult3.Content);
					}
				}
			}
			return result;
		}

		/// <summary>
		/// <b>[商业授权]</b> 读取PLC当前的程序的名称<br />
		/// <b>[Authorization]</b> Read the name of the current program of the PLC
		/// </summary>
		/// <returns>包含是否成的程序名称信息</returns>
		// Token: 0x06000BE2 RID: 3042 RVA: 0x00046528 File Offset: 0x00044728
		[HslMqttApi(Description = "Read the name of the current program of the PLC")]
		public OperateResult<string> ReadProgramName()
		{
			long currentValue = this.incrementCount.GetCurrentValue();
			byte code = 1;
			byte[] array = new byte[5];
			array[3] = 2;
			OperateResult<byte[]> operateResult = GeHelper.BuildReadCoreCommand(currentValue, code, array);
			bool flag = !operateResult.IsSuccess;
			OperateResult<string> result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<string>(operateResult);
			}
			else
			{
				OperateResult<byte[]> operateResult2 = base.ReadFromCoreServer(operateResult.Content);
				bool flag2 = !operateResult2.IsSuccess;
				if (flag2)
				{
					result = OperateResult.CreateFailedResult<string>(operateResult2);
				}
				else
				{
					OperateResult<byte[]> operateResult3 = GeHelper.ExtraResponseContent(operateResult2.Content);
					bool flag3 = !operateResult3.IsSuccess;
					if (flag3)
					{
						result = OperateResult.CreateFailedResult<string>(operateResult3);
					}
					else
					{
						result = GeHelper.ExtraProgramName(operateResult3.Content);
					}
				}
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.GE.GeSRTPNet.ReadPLCTime" />
		// Token: 0x06000BE3 RID: 3043 RVA: 0x000465C8 File Offset: 0x000447C8
		[DebuggerStepThrough]
		public Task<OperateResult<DateTime>> ReadPLCTimeAsync()
		{
			GeSRTPNet.<ReadPLCTimeAsync>d__19 <ReadPLCTimeAsync>d__ = new GeSRTPNet.<ReadPLCTimeAsync>d__19();
			<ReadPLCTimeAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult<DateTime>>.Create();
			<ReadPLCTimeAsync>d__.<>4__this = this;
			<ReadPLCTimeAsync>d__.<>1__state = -1;
			<ReadPLCTimeAsync>d__.<>t__builder.Start<GeSRTPNet.<ReadPLCTimeAsync>d__19>(ref <ReadPLCTimeAsync>d__);
			return <ReadPLCTimeAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.GE.GeSRTPNet.ReadProgramName" />
		// Token: 0x06000BE4 RID: 3044 RVA: 0x0004660C File Offset: 0x0004480C
		[DebuggerStepThrough]
		public Task<OperateResult<string>> ReadProgramNameAsync()
		{
			GeSRTPNet.<ReadProgramNameAsync>d__20 <ReadProgramNameAsync>d__ = new GeSRTPNet.<ReadProgramNameAsync>d__20();
			<ReadProgramNameAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
			<ReadProgramNameAsync>d__.<>4__this = this;
			<ReadProgramNameAsync>d__.<>1__state = -1;
			<ReadProgramNameAsync>d__.<>t__builder.Start<GeSRTPNet.<ReadProgramNameAsync>d__20>(ref <ReadProgramNameAsync>d__);
			return <ReadProgramNameAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc />
		// Token: 0x06000BE5 RID: 3045 RVA: 0x00046650 File Offset: 0x00044850
		public override string ToString()
		{
			return string.Format("GeSRTPNet[{0}:{1}]", this.IpAddress, this.Port);
		}

		// Token: 0x0400032E RID: 814
		private SoftIncrementCount incrementCount = new SoftIncrementCount(65535L, 0L, 1);
	}
}
